#!/bin/bash
source openrc.sh
yum install -y openstack-dashboard
crudini --set /etc/openstack-dashboard/local_settings '' OPENSTACK_HOST "$CONTROLLER_IP"
crudini --set /etc/openstack-dashboard/local_settings '' ALLOWED_HOSTS "['*']"
chown root:apache /etc/openstack-dashboard/local_settings
sed -i '6s/\/dashboard/\//' /etc/httpd/conf.d/openstack-dashboard.conf
sed -i '7s/\/dashboard//' /etc/httpd/conf.d/openstack-dashboard.conf 
tee >> /etc/openstack-dashboard/local_settings << EOF
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
CACHES = {
    'default': {
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
         'LOCATION': '$CONTROLLER_HOST_NAME:11211',
    }
}
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True

OPENSTACK_API_VERSIONS = {
    "identity": 3,
    "image": 2,
    "volume": 3,
}

OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = "Default"
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"
EOF
sed -i '4 i\WSGIApplicationGroup %{GLOBAL}' /etc/httpd/conf.d/openstack-dashboard.conf 
systemctl  restart httpd.service memcached.service
